function M = findFace2(Imm)
%FINDFACE Vrati oblast, ve ktere se nachazi oblicej

ImB = blur2(Imm);
[x0, y0] = findCenter(ImB);
M = regiongr2(ImB, x0, y0);
ImS = edge(Imm, 'sobel');
ImS(~M) = false;
if all(all(~ImS))
    [x1, y1] = findeCenter(M);
else
    [x1, y1] = findCenter(im2double(ImS));
end    
[x1, y1] = findCenter(M);
x0 = (x0 + 2*x1 + size(Imm, 2)/2)/4;
y0 = (y0 + 2*y1 + size(Imm, 1)/2)/4;
for s = 0:5:30
    if(s == 0)
        M = regiongr2(ImB, x0, y0);
    else        
        y1 = max(0,y0-s);
        y2 = min(size(Imm,1), y0+s);
        M = regiongr2(ImB, x0, y1) | regiongr2(ImB, x0, y2);
    end
    M = imgClose(M, 15);
    M = imopen(M, strel('disk', 10));
    q = sum(sum(M)) / numel(Imm);
    if (q > 0.5) | ((s == 0) & (q > 0.45))
        break;
    end
end
end

